<?php
	$ls_gridname	= 'dtl_pendidikan_pelamar';


// ----------------- >> Form Detail << ----------------- ?>
<script type="text/javascript">
	var controllerPendidikan = 'hrd_pendidikan_pelamar';
    var idPelamar = $('#id_pelamar_pk').val();

	$(document).ready(function(){
		// Setup Form
		$('#form_<?php echo $ls_gridname; ?>').setupForm([
			{ name: 'id_pendidikan_pelamar_pk', type:'text', size:'medium' },
			{ name: 'sekolah', type:'text', size:'medium', noempty:true },
			{ name: 'tahun_mulai', type: 'text', maxlength:'4' },
			{ name: 'tahun_selesai', type: 'text', maxlength:'4' },
			{ name: 'gelar', type: 'text', size:'long' },
			{ name: 'ket_pendidikan_pelamar', type: 'text', size:'long' }
		], {}, { prefix:'<?php echo $ls_gridname; ?>_' });
		
		// Set Hidden Object
		$('#<?php echo $ls_gridname; ?>_id_pendidikan_pelamar_pk').hide();
		
		// Create Dialog
		$('#form_<?php echo $ls_gridname; ?>_container').dialog({
			closed:true,
			modal:true,
			title: '_',
			width:550,
			height: 400,
			buttons:[{
				text:'Save',
				iconCls:'icon-save',
				handler:function(){
					$('#form_<?php echo $ls_gridname; ?>').submitForm('/'+controllerPendidikan+'/ajax_post/'+idPelamar, { onComplete : function(){ $('#form_<?php echo $ls_gridname; ?>_container').dialog('close'); 
						$('#<?php echo $ls_gridname; ?>').datagrid('reload'); }} );
				}
			},{
				text:'Close',
				iconCls:'icon-cancel',
				handler:function(){
					$('#form_<?php echo $ls_gridname; ?>_container').dialog('close');
				}
			}]
		});

	});
</script>
<div id="form_<?php echo $ls_gridname; ?>_container" style="padding:5px;width:600px;height:400px;">
	<div id="form_<?php echo $ls_gridname; ?>">
    <table class="tb_form" style="width:100%;" cellpadding="0" cellspacing="0">
    <tr>
        <td class="label">Nama Sekolah</td>
        <td><input id="sekolah" /><input id="id_pendidikan_pelamar_pk" /></td>
    </tr>
    <tr>
        <td class="label">Tahun Mulai</td>
        <td><input id="tahun_mulai" /></td>
    </tr>
    <tr>
        <td class="label">Tahun Selesai</td>
        <td><input id="tahun_selesai" /></td>
    </tr>
    <tr>
        <td class="label">Gelar</td>
        <td><input id="gelar" /></td>
    </tr>
    <tr>
        <td class="label">Keterangan</td>
        <td><input id="ket_pendidikan_pelamar" /></td>
    </tr>
    </table>
	</div>
</div>
<?php 



// ----------------- >> Table Detail << ----------------- ?>
<script type="text/javascript">
	$(document).ready(function(){
		$('#<?php echo $ls_gridname; ?>').datagrid({
			url:gs_path+'/'+controllerPendidikan+'/getdata/'+idPelamar,
			<?php if($mode!='view'){ 
			// -->> Toolbar [Start]
			// Only Appear On Mode Create / Edit ?>
			toolbar:[{
				text:'Tambah',
				iconCls:'icon-add',
				handler:function(){
					resetError();
					$('#<?php echo $ls_gridname; ?>_id_pendidikan_pelamar_pk').readonly();
					$('#form_<?php echo $ls_gridname; ?>_container').dialog('open');
					$('#form_<?php echo $ls_gridname; ?>').data('mode', 'create');
					$('#form_<?php echo $ls_gridname; ?>_container').prev().find('.panel-title').html('Tambah Data');
					
					$('#form_<?php echo $ls_gridname; ?>').resetForm();
					$('#form_<?php echo $ls_gridname; ?>').focusFirst();
				}
			},'-',{
				text:'Ubah',
				iconCls:'icon-edit',
				handler:function(){
					var oSel=$('#<?php echo $ls_gridname; ?>').datagrid('getSelected'); 
					if(oSel==null){ alert('Please select row!'); }
					else{ 
						resetError();
						$('#<?php echo $ls_gridname; ?>_id_pendidikan_pelamar_pk').readonly();
						$('#form_<?php echo $ls_gridname; ?>_container').dialog('open');
						$('#form_<?php echo $ls_gridname; ?>').data('mode', 'edit');
						$('#form_<?php echo $ls_gridname; ?>_container').prev().find('.panel-title').html('Ubah Data');
						
						jsonToForm(oSel, {prefix:'<?php echo $ls_gridname; ?>_'});
						$('#form_<?php echo $ls_gridname; ?>').focusFirst();
					}
				}
			},'-',{
				text:'Hapus',
				iconCls:'icon-remove',
				handler:function() {
					var oSel = $('#<?php echo $ls_gridname; ?>').datagrid('getSelected'); 
                    if (oSel == null) { 
                        $.messager.alert('&nbsp;', gs_msg_row_unselected, 'warning'); 
                    } else { 
                        var url = gs_path+'/'+controllerPendidikan+'/ajax_delete?id_pendidikan_pelamar_pk='+oSel.id_pendidikan_pelamar_pk;
                        // Confirm Hapus
						$.messager.confirm('Confirm', 'yakin menghapus data ini?', function(r){
			                if (r){
			                    $.get( url, function(  ) {
								  	$('#<?php echo $ls_gridname; ?>').datagrid('reload');
								});
			                }
			            });
                    } 

				}
			}],<?php 
			} // -->> Toolbar [End]
			?>
			onClickRow:function(rowIndex){
				var lastIndex = $('#<?php echo $ls_gridname; ?>').data('selectedIndex');
				$('#<?php echo $ls_gridname; ?>').data('selectedIndex', rowIndex);
			},
			onLoadSuccess:function(){ }
		});
	});
	
</script>
<table id="<?php echo $ls_gridname; ?>" style="width:600;height:auto" singleSelect="true" idField="index_no" showFooter="true">
<thead>
    <tr>
    	<th field="id_pendidikan_pelamar_pk" hidden="true"></th>
        <th field="sekolah" width="150" >Nama Sekolah</th>
        <th field="tahun_mulai" width="100" >Tahun Mulai</th>
        <th field="tahun_selesai" width="100" >Tahun Selesai</th>
        <th field="gelar" width="150" >Gelar</th>
        <th field="ket_pendidikan_pelamar" width="250" >Keterangan</th>
    </tr>
</thead>
</table>
